$(function(){
	var URL = {
			saveUrl:ctx+"/background/company/save.do"
	};
	
	var modelName = "company";
	
	var form = $("#"+modelName+"_form");
	
	bindBtns();
	/** 绑定按钮 **/
	function bindBtns(){
		$("#"+modelName+"_savebtn").bind("click",function(){
			save();
		});
	}
	/** 保存 **/
	function save(){
		if(form.form("validate")){
			var formData = seriData(form.serializeArray());
			$.messager.confirm("提示",Msg.saveCfm,function(r){
				if(r){
					$.messager.progress({
						title:"系统提示",
						msg:"",
						text:"保存中..."
					}); 
					$.ajax({
						url : URL.saveUrl,
						type : "post",
						data : formData,
						success : function(data){
							$.messager.progress("close");
							if(data.success){
								showMsg(Msg.saveSuc);
								$("#"+modelName+"_formWin").window("destroy");
								$("#"+modelName + "_table").datagrid("reload");
							}else{
								showMsg(data.returnMsg);
							}
						}
					});
				}
			});
		}
	}
	
	seriImgUploader();
	function seriImgUploader(){
		var materialupload = $("#"+modelName+"_form_files").seriUploader({
			width : "140px",
			height : "150px",
			url : ctx + "/file/fileupload",
			backurl : ctx + "/file/image/",
			maxSize : 5120,
			maxNum:1,
			name:"head",
			btnName : "上传头像",
			outSize : function(size){
				showMsg("您选择的图片不能超过"+size+"kb，请重新选择");
			}
		});
	}
	
});